/* Table 2 */
clear
clear mata
clear matrix
set maxvar 10000
use  "[path]\Table 2.dta"
xtset sic2
xtprobit f1useconsultant union_perc logat mtbrW netppeW firmriskW roaW mraw_window_1W lfirmage y_*, pa vce(robust)
areg f1useconsultant union_perc logat mtbrW netppeW firmriskW roaW mraw_window_1W lfirmage, absorb(id3) robust cluster(gvkey) 			
xtprobit f1useconsultant union_perc union_nonrtw nonrtw  logat mtbrW netppeW firmriskW roaW mraw_window_1W lfirmage y_*, pa vce(robust) 			
xtprobit f1useconsultant union_perc logat mtbrW netppeW firmriskW roaW mraw_window_1W lfirmage lage ltenure ceochair lbsize perind perind69 perindbusy y_*, pa vce(robust) 			
xtprobit f1useconsultant union_perc logat mtbrW netppeW firmriskW roaW mraw_window_1W lfirmage lage ltenure ceochair lbsize perind perind69 perindbusy region1-region10 i.fyear, vce(robust) 			
xtprobit f1useconsultant union_perc union_nonrtw nonrtw logat mtbrW netppeW firmriskW roaW mraw_window_1W lfirmage lage ltenure ceochair lbsize perind perind69 perindbusy y_*, pa vce(robust)			

/* Table 3 */
clear
clear mata
clear matrix
set maxvar 10000
use  "[path]\Table 3.dta"
xtset sic2
xtprobit useconsultant contract contract_nonrtw nonrtw y_*, pa vce(robust)
xtprobit useconsultant contract contract_nonrtw nonrtw logat mtbrW netppeW firmriskW roaW mraw_window_1W lfirmage founder lage ltenure ceochair lbsize perind perind69 perindbusy y_*, pa vce(robust)			

/* Table 4 */
clear
clear mata
clear matrix
set maxvar 10000
use  "[path]\Table 4.dta"
didregress (f1useconsultant logat mtbrW netppeW firmriskW roaW mraw_window_1W lfirmage) (did), group(unionized) aeq time(fyear) vce(cluster gvkey)
// lowtech and hightech subsets
didregress (f1useconsultant logat mtbrW netppeW firmriskW roaW mraw_window_1W lfirmage) (did) if lowtech==1, group(unionized) time(fyear) vce(cluster gvkey)
didregress (f1useconsultant logat mtbrW netppeW firmriskW roaW mraw_window_1W lfirmage) (did) if hightech==1, group(unionized) time(fyear) vce(cluster gvkey)
// positive and negative adjusted vega
drop if lvega==.
by sic2 fyear, sort: egen totallvega = total(lvega)
by sic2 fyear: gen avg_lvega = (totallvega-lvega)/(_N-1)
gen adjlvega = lvega  - avg_lvega
didregress (f1useconsultant logat mtbrW netppeW firmriskW roaW mraw_window_1W lfirmage) (did) if adjlvega>0, group(unionized) time(fyear) vce(cluster gvkey)
didregress (f1useconsultant logat mtbrW netppeW firmriskW roaW mraw_window_1W lfirmage) (did) if adjlvega<0, group(unionized) time(fyear) vce(cluster gvkey)

/* Table 5 */
clear
clear mata
clear matrix
set maxvar 10000
use  "[path]\Table 5.dta"
cluster2 ltotal_fees vmem vmem_nonrtw nonrtw logat leverageW lfirmage tangibilityW rdassetsW roaW lagstdebitdaassets5W newceo lage ltenure ceochair  sic2_* y_*, tcluster(fyear) fcluster(cic) 
cluster2 ltotal_otherfees vmem vmem_nonrtw nonrtw  logat leverageW lfirmage tangibilityW rdassetsW roaW  lagstdebitdaassets5W newceo lage ltenure ceochair   sic2_* y_*, tcluster(fyear) fcluster(cic) 
cluster2 lfeesplusother vmem vmem_nonrtw nonrtw logat leverage lfirmage tangibility rdassets roa lagstdebitdaassets5W newceo lage ltenure ceochair  sic2_* y_*, tcluster(fyear) fcluster(cic) 
cluster2 lfeeratio vmem vmem_nonrtw nonrtw logat leverageW lfirmage tangibilityW rdassetsW roaW  lagstdebitdaassets5W newceo lage ltenure ceochair  sic2_* y_*, tcluster(fyear) fcluster(cic) 

cluster2 ltotal_fees union_perc unionperc_nonrtw nonrtw logat leverageW lfirmage tangibilityW rdassetsW roaW  lagstdebitdaassets5W newceo lage ltenure ceochair  sic2_* y_*, tcluster(fyear) fcluster(gvkey) 
cluster2 ltotal_otherfees union_perc unionperc_nonrtw nonrtw logat leverageW lfirmage tangibilityW rdassetsW roaW  lagstdebitdaassets5W newceo lage ltenure ceochair  sic2_* y_*, tcluster(fyear) fcluster(gvkey) 
cluster2 lfeesplusother union_perc unionperc_nonrtw nonrtw logat leverage lfirmage tangibility rdassets roa lagstdebitdaassets5W newceo lage ltenure ceochair  sic2_* y_*, tcluster(fyear) fcluster(gvkey) 
cluster2 lfeeratio union_perc unionperc_nonrtw nonrtw logat leverageW lfirmage tangibilityW rdassetsW roaW  lagstdebitdaassets5W newceo lage ltenure ceochair  sic2_* y_*, tcluster(fyear) fcluster(gvkey) 


/* Table 7 */
clear
clear mata
clear matrix
set maxvar 10000
use  "[path]\Table 7.dta"
calipmatch, casevar(noconsult) generate(pairid) maxmatches(1) ///
   exactmatch(fyear sic2) calipermatch(logat mtbrW netppeW firmriskW roaW mraw_window_1W lfirmage lage ltenure ceochair lbsize perind perind69 perindbusy) caliperwidth(1 1 1 1 1 1 1 1 1 1 1 1 1 1)

drop if pairid==.

ttest vmem, by(noconsult)
ttest lcashcomp, by(noconsult)
ttest lequity, by(noconsult)
ttest lstockawards, by(noconsult)
ttest loptionawards, by(noconsult)
ttest lvega, by(noconsult)

kwallis vmem, by(noconsult)
kwallis lcashcomp, by(noconsult)
kwallis lequity, by(noconsult)
kwallis lstockawards, by(noconsult)
kwallis loptionawards, by(noconsult)
kwallis lvega, by(noconsult)


/* Table 8 */
clear
clear mata
clear matrix
set maxvar 10000
use  "[path]\Table 8.dta"
areg ltdc1 vmem vmem_noconsult noconsult logat mraw_window_1W lagmraw_window_1W roaW lagroaW lagleverageW lagbmW lagstdebitdaassets5W lagcapexW lagtangibilityW lagsalesgW lagrdassetsW ltenure ceochair lindcapitallaborW lindfirmageW indrdassetsW i.fyear if fyear>= 2006, absorb(gvkey) robust cluster(cic) 
areg lcashcomp vmem vmem_noconsult noconsult logat mraw_window_1W lagmraw_window_1W roaW lagroaW lagleverageW lagbmW lagstdebitdaassets5W lagcapexW lagtangibilityW lagsalesgW lagrdassetsW ltenure ceochair lindcapitallaborW lindfirmageW indrdassetsW i.fyear if fyear>= 2006, absorb(gvkey) robust cluster(cic) 
areg lequity vmem vmem_noconsult noconsult logat mraw_window_1W lagmraw_window_1W roaW lagroaW lagleverageW lagbmW lagstdebitdaassets5W lagcapexW lagtangibilityW lagsalesgW lagrdassetsW ltenure ceochair lindcapitallaborW lindfirmageW indrdassetsW i.fyear if fyear>= 2006, absorb(gvkey) robust cluster(cic) 
areg perstockpay vmem vmem_noconsult noconsult logat mraw_window_1W lagmraw_window_1W roaW lagroaW lagleverageW lagbmW lagstdebitdaassets5W lagcapexW lagtangibilityW lagsalesgW lagrdassetsW ltenure ceochair lindcapitallaborW lindfirmageW indrdassetsW i.fyear if fyear>= 2006, absorb(gvkey) robust cluster(cic) 
areg peroptionpay vmem vmem_noconsult noconsult logat mraw_window_1W lagmraw_window_1W roaW lagroaW lagleverageW lagbmW lagstdebitdaassets5W lagcapexW lagtangibilityW lagsalesgW lagrdassetsW ltenure ceochair lindcapitallaborW lindfirmageW indrdassetsW i.fyear if fyear>= 2006, absorb(gvkey) robust cluster(cic) 
areg lvega vmem vmem_noconsult noconsult logat mraw_window_1W lagmraw_window_1W roaW lagroaW lagleverageW lagbmW lagstdebitdaassets5W lagcapexW lagtangibilityW lagsalesgW lagrdassetsW ltenure ceochair lindcapitallaborW lindfirmageW indrdassetsW i.fyear if fyear>= 2006, absorb(gvkey) robust cluster(cic) 
	

/* Table 9 */
clear
clear mata
clear matrix
set maxvar 10000
use  "[path]\Table 9.dta"
reg3 (useconsultant vmem logat mtbrW netppeW firmriskW roaW mraw_window_1W lfirmage lage ltenure ceochair lbsize perind perind69 perindbusy i.fyear i.sic2) /// 
(lcashcomp vmem vmem_useconsult useconsultant logat mraw_window_1W lagmraw_window_1W roaW lagroaW lagleverageW lagbmW lagstdebitdaassets5W lagcapexW lagtangibilityW lagsalesgW lagrdassetsW ltenure ceochair lindcapitallaborW lindfirmageW indrdassetsW i.fyear i.sic2) if fyear>= 2006 & rtw==1, sure

reg3 (useconsultant vmem logat mtbrW netppeW firmriskW roaW mraw_window_1W lfirmage lage ltenure ceochair lbsize perind perind69 perindbusy  i.fyear i.sic2) /// 
(lcashcomp vmem vmem_useconsult useconsultant logat mraw_window_1W lagmraw_window_1W roaW lagroaW lagleverageW lagbmW lagstdebitdaassets5W lagcapexW lagtangibilityW lagsalesgW lagrdassetsW ltenure ceochair lindcapitallaborW lindfirmageW indrdassetsW i.fyear i.sic2) if fyear>= 2006 & nonrtw==1, sure

reg3 (useconsultant vmem logat mtbrW netppeW firmriskW roaW mraw_window_1W lfirmage lage ltenure ceochair lbsize perind perind69 perindbusy i.fyear i.sic2) /// 
(lequity vmem vmem_useconsult useconsultant logat mraw_window_1W lagmraw_window_1W roaW lagroaW lagleverageW lagbmW lagstdebitdaassets5W lagcapexW lagtangibilityW lagsalesgW lagrdassetsW ltenure ceochair lindcapitallaborW lindfirmageW indrdassetsW i.fyear i.sic2) if fyear>= 2006 & rtw==1, sure

reg3 (useconsultant vmem logat mtbrW netppeW firmriskW roaW mraw_window_1W lfirmage lage ltenure ceochair lbsize perind perind69 perindbusy  i.fyear i.sic2) /// 
(lequity vmem vmem_useconsult useconsultant logat mraw_window_1W lagmraw_window_1W roaW lagroaW lagleverageW lagbmW lagstdebitdaassets5W lagcapexW lagtangibilityW lagsalesgW lagrdassetsW ltenure ceochair lindcapitallaborW lindfirmageW indrdassetsW i.fyear i.sic2) if fyear>= 2006 & nonrtw==1, sure
	